home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer)…68k, x86, SPARC, PA-RISC] / NeXTSTEP 3.3 Dev Intel.iso / NextDeveloper / Headers / btree / IXBTreeCursor.h < prev    next >
Text File  |  1993-08-15  |  3KB  |  88 lines

  1. /*
  2. IXBTreeCursor.h
  3. Copyright 1991, NeXT, Inc.
  4. */
  5.  
  6. #import    "IXBTree.h"
  7.  
  8. #ifdef    NX_COMPILER_RELEASE_3_0
  9. @interface IXBTreeCursor : Object <IXCursorPositioning>
  10. #else    NX_COMPILER_RELEASE_3_0
  11. @interface IXBTreeCursor : Object
  12. #endif    NX_COMPILER_RELEASE_3_0
  13. {
  14.     struct BTree        *btree;
  15.     void            *keyBuffer;
  16.     unsigned            keyLength;
  17.     unsigned            bufferSize;
  18.     unsigned            storeVersion;
  19.     unsigned            keyLimit;
  20.     unsigned            traceHint;
  21.     unsigned            cursorVersion;
  22.     unsigned            cursorDepth;
  23.     NXZone            *cursorZone;
  24.     struct BTreeTraceRecord    *cursorTrace;
  25.     struct            {
  26.     unsigned        isSpanning:1;
  27.     unsigned        rightRotation:1;
  28.     unsigned        leftRotation:1;
  29.     unsigned        traceNeeded:1;
  30.     unsigned        traceOpened:1;
  31.     unsigned        zeroPosition:1;
  32.     unsigned        lastPosition:1;
  33.     }                cursorStatus;
  34. }
  35.  
  36. - (IXBTree *)btree;
  37. - initWithBTree:(IXBTree *)aBTree;
  38.  
  39. // these methods provided for subclasses.  isSynchronized returns FALSE when 
  40. // the btree has been modified by another cursor, or the last change to the 
  41. // btree destroyed the synchronization.  use setKey:andLength: to synchronize
  42. // or isMatch or getKey:andLength: if still using the same key.  changeCount 
  43. // returns the btree's notion of the store's change count.  If this is stale,  
  44. // synchronization is necessary.
  45.  
  46. - (BOOL)isSynchronized;
  47. - (unsigned)changeCount;
  48.  
  49. // the value is a pointer to a buffer.  if zero, a buffer will be allocated.  
  50. // if non- zero, it will be interpreted as a buffer pointer.  do not pass an
  51. // uninitialized pointer.
  52.  
  53. - (unsigned)readValue:(void **)value; // reads the value and returns length
  54. - (unsigned)readRange:(void **)value // reads part of the value
  55.     ofLength:(unsigned)length atOffset:(unsigned)offset;
  56.  
  57. - removeValue; // removes the key/value pair from the B* tree
  58.  
  59. - (BOOL)writeValue:(const void *)value // replaces if key exists, else inserts
  60.     andLength:(unsigned)length;
  61. - writeRange:(const void *)value 
  62.     ofLength:(unsigned)length atOffset:(unsigned)offset;
  63.  
  64. // these interpret the value at the cursor location as a typed stream archive.
  65.  
  66. - readObject;
  67. - readObjectFromZone:(NXZone *)zone;
  68. - (BOOL)writeObject:anObject;
  69.  
  70. // returns a pointer to a potentially write mapped page.  use at your own risk.
  71. // it is fast, since it saves copying, but if you modify the value incorrectly, 
  72. // you may damage the btree.
  73.  
  74. - (unsigned)openRange:(void **)value 
  75.     ofLength:(unsigned)length atOffset:(unsigned)offset 
  76.     forWriting:(BOOL)writing;
  77.  
  78. // store hints in secondary btrees to locate primary keys quickly for read 
  79. // only or read mostly btrees. hints may actually diminish performance when 
  80. // use with frequently modified btrees.
  81.  
  82. - (BOOL)getKey:(void **)key // returns hint for cursor position
  83.     andLength:(unsigned *)length withHint:(unsigned *)hint;
  84. - (BOOL)setKey:(const void *)key // sets key with hint returned by preceding
  85.     andLength:(unsigned)length withHint:(unsigned)hint;
  86.  
  87. @end
  88.